package com.haorui.lygyd.authority.authentication;

import lombok.Getter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;

import java.util.Collection;

/**
 * @author 陈刚
 * @version 1.0
 * @project znsm
 * @package com.haorui.znsm.authority.authentication
 * @createDate 2018-03-16 14:18
 * @modfiyDate
 * @function
 */
public class MemberAuthenticationToken extends AbstractAuthenticationToken {
    private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

    // ~ Instance fields
    // ================================================================================================

    private String wxUserName;
    private String wxPassword;
    @Getter
    private String openId;

    // ~ Constructors
    // ===================================================================================================

    /**
     * This constructor can be safely used by any code that wishes to create a
     * <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
     * will return <code>false</code>.
     *
     */
    public MemberAuthenticationToken(String wxUserName, String wxPassword,String openId) {
        super(null);
        this.wxUserName = wxUserName;
        this.wxPassword = wxPassword;
        this.openId= openId;
    }




    @Override
    public Object getCredentials() {
        return this.wxPassword;
    }
    @Override
    public Object getPrincipal() {
        return this.wxUserName;
    }


    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
        wxPassword = null;
    }
}
